<?php
namespace app\adminxcx\controller;
use \think\Controller;
use app\admin\model\User as UserModel;
use app\admin\model\Log as LogModel;


class Log extends Controller
{

    protected $UserModel;
    protected $LogModel;


    public function __construct()
    {
        if(!session('uid')){
            $this->redirect('index/index');
        }
        $this->UserModel = new UserModel();
        $this->LogModel = new LogModel();
        
    }

    public function index($cid)
    {
        return view('index',[
            'cid' => $cid
        ]);
    }

    public function type($cid)
    {
        return view('type',[
            'cid' => $cid
        ]);
    }

    public function typeLst($cid,$type)
    {
        return view('typelst',[
            'cid' => $cid,
            'type' => $type
        ]);
    }


    public function lst($cid,$type=100){
        if($type == 100){
            $query = [
                'ispage' => true,
                'limit' => 20,
                'where' => [
                    'cid' => $cid
                ],
                'order' => [
                    'create_time' => 'desc'
                ]
            ];
        }else{
            $query = [
                'ispage' => true,
                'limit' => 20,
                'where' => [
                    'cid' => $cid,
                    'type' => $type
                ],
                'order' => [
                    'create_time' => 'desc'
                ]
            ];
        }
        $LogRes = $this->LogModel-> getLst($query);
        return json($LogRes);
    }

    


    
 
}
